public class CXGCampaignMemberAccountUpdate{

public static void CampaignMemberToAccountUpdate(Set<Id> CampMemList){

ID CxGcampaignmemberrecordtypeID = RecordTypeHelper.GetRecordTypeIdByDevName('CXG_Campaign_Accounts__c', 'Campaign_Member');       
ID CxGacctRecordtypID = RecordTypeHelper.GetRecordTypeIdByDevName('Account', 'CSS_Customer');     

Set<ID> AccountSet= new Set<ID>();
List<Account> AccountList = new List<Account>();
List<Account> AccountUpdateList = new List<Account>();

       
    AccountList = [Select Control_Group__c,RecordTypeId from Account where Id in : CampMemList AND RecordTypeId=:CxGacctRecordtypID ];
    for(Account acct: AccountList){
    acct.Control_Group__c=True;
    AccountUpdateList.add(acct);
    
    } 
      try
      { 
       update AccountUpdateList;
      }
      catch(Exception exe)
      {
       system.debug(exe);
      }
}

@isTest(seeAllData=True) 
static void cxgTest(){ 

    ID cxgacctRecordtypID = RecordTypeHelper.GetRecordTypeIdByDevName('Account', 'CSS_Customer');
    ID cxgcampaignmemberrecordtypeID = RecordTypeHelper.GetRecordTypeIdByDevName('CXG_Campaign_Accounts__c', 'Campaign_Member');
    ID cxgcampaignrecordtypeID = RecordTypeHelper.GetRecordTypeIdByDevName('Campaign', 'CXG_Campaign');
    Account cxgAccount = new Account();
    cxgAccount.Name = 'TestAccount1';
    cxgAccount.Control_Group__c = False;
    cxgAccount.RecordTypeId = cxgacctRecordtypID;
    Insert cxgAccount;
    
    Campaign cxgCampaign = new Campaign();
    cxgCampaign.Name = 'CheckTest';
    cxgCampaign.RecordTypeId = cxgcampaignrecordtypeID;
    cxgCampaign.Number_of_Control_Group_Members__c = 0;
    cxgCampaign.IsActive = True;
    insert cxgCampaign;
    
    CXG_Campaign_Accounts__c cxgCampMem = new CXG_Campaign_Accounts__c();
    cxgCampMem.Campaign__c = cxgCampaign.Id;
    cxgCampMem.Customer__c = cxgAccount.Id;
    cxgCampMem.RecordTypeId = cxgcampaignmemberrecordtypeID;
    cxgCampMem.Control_Group_Member__c = false;
    cxgCampMem.Status__c = 'New';
    insert cxgCampMem;  
    test.startTest();
              
    cxgCampMem.Control_Group_Member__c = true;
    update cxgCampMem;  
    test.stopTest();   
}
}